<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>

<body>
  <input type="text" id="ipt"> 搜索

  <script>
    function debouce(fn, delay = 200) {
      let timer = 0;
      return function () {
        if (timer) clearTimeout(timer)
        timer = setTimeout(() => {
          fn.apply(this, arguments)
        }, delay)
      }
    };

    let ipt = document.getElementById("ipt");
    ipt.addEventListener('keyup', debouce(() => {
      console.log("发起搜索", ipt.value);
    }, 1000))
  </script>
</body>

</html>